﻿using System;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Quartz;
using RayD.App.SystemModule;
using RayD.Core;
using RayD.Repository;

namespace RayD.App.Quartz.Jobs
{
    [Description("定时日志任务")]
    public class TestJob : IJob
    {
        //这样可以获取指定数据库仓储
        //private IRepository _repository = new BaseRepository(AppSettings.DefaultDb);

        private JobApp _jobService;
        public TestJob(JobApp jobService)
        {
            this._jobService = jobService;
        }

        public Task Execute(IJobExecutionContext context)
        {
            var jobId = context.MergedJobDataMap.GetString(Define.JOBMAPKEY);
            _jobService.Record(jobId);
            //todo:这里可以加入自己的自动任务逻辑

            return Task.CompletedTask;
        }
    }
}
